<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
class OrderController extends Controller
{
    //index
    public function index()
    {
    	$data = DB::table('order') -> get();
    	// dd($data);
    	return view('/admin/order/order/order',['data'=>$data]);
    }


    //编辑订单状态
    public function statusedit($id)
    {
    	$data = DB::table('order') -> where('order_id',$id) -> first();
    	return view('/admin/order/order/statusedit',['data'=>$data]);	
    }

    //更新订单状态
    public function update(Request $request)
    {
    	$data = $request -> except('_token');
    	// dd($data);
    	$res = DB::table('order') -> where('order_id',$data['order_id']) -> update(['ord_state'=>$data['ord_state'],'waybill_code'=>$data['waybill_code']]);
    	if($res)
    	{
    		return redirect('admin/order') -> with('success','订单状态修改成功');
    	}else{
    		return back() -> with('error','订单状态修改失败');
    	}
    }
}
